type ShowModalOptions = {
    title?: string
    content: string
    showCancel?: boolean
    cancelText?: string
    cancelColor?: string
    confirmText?: string
    confirmColor?: string
}

export function Modal(options: ShowModalOptions): Promise<boolean> {
    return new Promise((resolve, reject) => {
        uni.showModal({
            title: options.title ?? '提示',
            content: options.content,
            showCancel: options.showCancel ?? true,
            cancelText: options.cancelText ?? '取消',
            cancelColor: options.cancelColor ?? '#000000',
            confirmText: options.confirmText ?? '确定',
            confirmColor: options.confirmColor ?? '#169bd5',
            success(res) {
                if (res.confirm) return resolve(true)
                if (res.cancel) return resolve(false)
            },
            fail(err) {
                reject(err)
            },
        })
    })
}
